<?
//============
//seo三要素信息
//============


//读取网站seo
$seo_site = select_one_line_all_items($table_Prefix . "site", " nid = '0' ");

//读取板块seo
$seo_plate = select_one_line_all_items($table_Prefix . "plate", " sys_belong = '".$system_part."' ");



//$seo_part来自router,首页为空
if($seo_part == ''){
    $page_title       = $seo_site['title'];
    $page_description = $seo_site['description'];
    $page_keyword     = $seo_site['keyword'];
}



//这里应该拼装板块的seo信息



//拼装分类列表SEO信息
elseif($seo_part == 'term'){
    $seo_type = explode(',',$seo_plate['seo_term']);

    if(in_array('site',$seo_type)){
        $page_title       = $seo_site['title'];
        $page_description = $seo_site['description'];
        $page_keyword     = $seo_site['keyword'];
    }
    if(in_array('plate',$seo_type)){
        $page_title       = $seo_plate['title']      ." ".$page_title;
        $page_description = $seo_plate['description']." ".$page_description;
        $page_keyword     = $seo_plate['keywords']    ." ".$page_keyword;
    }
}




//拼装详情列表SEO信息
elseif($seo_part == 'list'){

    $seo_type = explode(',',$seo_plate['seo_list']);

    if(in_array('site',$seo_type)){
        $page_title       = $seo_site['title'];
        $page_description = $seo_site['description'];
        $page_keyword     = $seo_site['keyword'];
    }
    if(in_array('plate',$seo_type)){
        $page_title       = $seo_plate['title']      ." ".$page_title;
        $page_description = $seo_plate['description']." ".$page_description;
        $page_keyword     = $seo_plate['keywords']    ." ".$page_keyword;
    }
    if(in_array('list',$seo_type)){

        $now_term = select_one_line_all_items($table_Prefix . "term", " url = '".$route."' ");

        $page_title       = $now_term['title']  ." ".$page_title;
        $page_description = $now_term['keyword']." ".$page_description;
        $page_keyword     = $now_term['title']  ." ".$page_keyword;

    }
}



//拼装详情页SEO信息
elseif($seo_part == 'detail'){

    $seo_type = explode(',',$seo_plate['seo_detail']);
    $now_detail = select_one_line_all_items($table_Prefix . "detail", " url = '" . $route . "' ");

    //通过详情反推所属分类
    $_termlist=select_lines_all_items($table_Prefix . "relation","","detail_nid = '".$now_detail['nid']."' ","");
    $_termlist_1d=transform_2darray_in_1darray_number_as_key($_termlist,"term_nid");
    $_termlist_str=implode("','",$_termlist_1d);
    $_now_termlist = select_lines_all_items($table_prefix."term","","nid in ('".$_termlist_str."')","");


    //提取二位数组中的seo信息，转化成字符串。
    $_now_term_title_list=transform_2darray_in_1darray_number_as_key($_now_termlist,"title");
    $now_term['title']=implode(" ",$_now_term_title_list);

    $_now_term_title_list=transform_2darray_in_1darray_number_as_key($_now_termlist,"description");
    $now_term['description']=implode(" ",$_now_term_title_list);

    $_now_term_title_list=transform_2darray_in_1darray_number_as_key($_now_termlist,"keyword");
    $now_term['keyword']=implode(" ",$_now_term_title_list);



    //是否需要组合网站的seo信息
    if(in_array('site',$seo_type)){
        $page_title       = $seo_site['title'];
        $page_description = $seo_site['description'];
        $page_keyword     = $seo_site['keyword'];
    }

    //是否需要组合板块的seo信息；板块的keyword带s
    if(in_array('plate',$seo_type)){

        $page_title       = $seo_plate['title']      ." ".$page_title;
        $page_description = $seo_plate['description']." ".$page_description;
        $page_keyword     = $seo_plate['keywords']    ." ".$page_keyword;
    }

    //是否需要组合分类的seo信息；这个是详情列表页面用到
    if(in_array('list',$seo_type)){


        $page_title       = $now_term['title']  ." ".$page_title;
        $page_description = $now_term['keyword']." ".$page_description;
        $page_keyword     = $now_term['title']  ." ".$page_keyword;

    }


    //是否需要组合详情的的seo信息；这个是详情列表页面用到
    if(in_array('detail',$seo_type)){

        $page_title       = $now_detail['title']  ." ".$page_title;
        $page_description = $now_detail['description']  ." ".$page_description;
        $page_keyword     = $now_detail['keyword']  ." ".$page_keyword;

    }

}



$_data['seo']['title']       = $page_title;
$_data['seo']['description'] = $page_description;
$_data['seo']['keyword']     = $page_keyword;



//============
//seo三要素信息
//============


?>